﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StudentMgmt.IDAL;
using StudentMgmt.Model;
using StudentMgmt.Model.DataContext;
using System.Data;
using System.Data.SqlClient;
using StudentMgmt.DBUtility;
using System.Windows.Forms;

namespace StudentMgmt.SQLServerDAL
{
    public   class Rewards:IReward
    {
        public  int QueryRewards(string StuNo, out DataTable mytabel)
        {
            int val = 0 ;
            StringBuilder builder = new StringBuilder();
            builder.Append("select  rwd.StuNo as '学号', rwdConfig.Reward_Descriptions as '奖励类型', rwd.Create_Date as '创建日期', rwd.Reward_Descriptions as '说明' ");
            builder.Append("from Reward as rwd inner join Reward_Levels_Config as rwdConfig on rwd.Reward_Code=rwdConfig.Reward_Code ");
            builder.Append("where rwd.StuNo='"+StuNo+"'");
            val = SqlHelper.RunSQLReturnDataTable(builder.ToString(), out mytabel);
            return val;
        }
       public   void InsertReward(RewardInfo reward)
        {
            StudentMgmtDataContext db = new StudentMgmtDataContext();
            db.Rewards.InsertOnSubmit(reward);
            db.SubmitChanges();
        }
    }
}
